#!/usr/bin/env python
#-*- coding:gbk -*-
u'''
@file args.py
@brief args
@author hulei
@version 1.0
@date 2012-08-15
@copyright 2012 Hulei. All rights reserved.
'''

def to_windows_arg(s):
    s = s.strip()
    ret = []
    has_blank = 0
    for c in s:
        if c in ['\t', ' ', '|', '&', '^']:
            has_blank = 1
            ret.append(c)
        elif c == '"':
            ret.append('"""')
        else:
            ret.append(c)
    if len(ret) == 0 or has_blank:
        ret.insert(0, '"')
        ret.append('"')
    return ''.join(ret)

__all__ = ['to_windows_arg']
